package datasv.studentQuery_datasv;

import java.util.Date;

import data.datafactory.DatabaseOperator;
import po.StudentPO;

public class GetStudent {
	public static void main(String[] args) {
		System.out.println(new GetStudent().getStudent("001131001"));
	}
	public StudentPO getStudent(String id){
		return getInSql(id);
	}
	private StudentPO getInSql(String id){
		String collegeID=id.substring(0,3);
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		if(!op.ifDatabaseExist()||!op.ifIDExist("student_list", id)){
			return null;
		}
		String listName="student_list";
		String n=op.getOneInform(id, listName, "name");
		String bir=op.getOneInform(id, listName, "birthday");
		String[] m=bir.split("/");
		Date b=new Date(Integer.parseInt(m[0]),Integer.parseInt(m[1]),Integer.parseInt(m[2])); 
		String c=op.getOneInform(id, listName, "collegeID");
		String d=op.getOneInform(id, listName, "department");
		String year=op.getOneInform(id, listName, "educateStartYear");
		return new StudentPO(id, n, b, c, d, Integer.parseInt(year));
	}
	
}
